<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.20"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Detail: guild/guild_saver.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Detail
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.20 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_c92f8b0c436b7cf5413a5c6644bc0ce0.html">guild</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">guild_saver.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="guild__saver_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160; </div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="preprocessor">#pragma once</span></div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160; </div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="preprocessor">#include &lt;sstream&gt;</span></div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160; </div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="guild_8h.html">guild/guild.h</a>&quot;</span></div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="service__redis__fwd_8hpp.html">redis/service_redis_fwd.hpp</a>&quot;</span></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160; </div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="keyword">namespace </span>guild_service {</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="keyword">namespace </span>detail {</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160; </div>
<div class="line"><a name="l00040"></a><span class="lineno"><a class="line" href="guild__saver_8hpp.html#a86cddb3a9044df2a4587caca07618cf2">   40</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="guild__saver_8hpp.html#a86cddb3a9044df2a4587caca07618cf2">SaveLastGuildId</a>(<span class="keyword">const</span> std::string &amp;service_name,</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;                     <span class="keyword">const</span> <a class="code" href="guild_8h.html#a1c8a386d9790b05f2665f3e786b8d983">guild_id_type</a> guild_id) {</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;  std::stringstream ss;</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;  ss &lt;&lt; <span class="stringliteral">&quot;SET lastguildid &quot;</span> &lt;&lt; guild_id;</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;  <span class="keyword">auto</span> result = redis_command_co(service_name, ss.str(), <a class="code" href="service__redis__client_8hpp.html#a1d1da97ea7897858a311261ebd3f59c6">kRedisCommonTimeOut</a>);</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;  <span class="keywordflow">if</span> (!result) {</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;    LOG_FAIL(<span class="stringliteral">&quot;redis处理失败 命令:%s 服务名:%s&quot;</span>, ss.str().c_str(),</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;             service_name.c_str());</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;  }</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160; </div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;  <span class="keywordflow">if</span> (!result-&gt;is_success()) {</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;    LOG_FAIL(<span class="stringliteral">&quot;redis处理失败 命令:%s 错误:%s 错误码:%u 服务名:%s&quot;</span>,</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;             result-&gt;get_command().c_str(), result-&gt;get_error().c_str(),</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;             <span class="keyword">static_cast&lt;</span>uint32_t<span class="keyword">&gt;</span>(result-&gt;get_error_code()),</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;             service_name.c_str());</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;  }</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160; </div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;  LOG_DEBUG(<span class="stringliteral">&quot;redis同步保存公会id成功 命令:%s 服务名:%s&quot;</span>,</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;            result-&gt;get_command().c_str(), service_name.c_str());</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160; </div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;}</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160; </div>
<div class="line"><a name="l00075"></a><span class="lineno"><a class="line" href="guild__saver_8hpp.html#a4f04165526e37b9bc9715e2152600b14">   75</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="guild__saver_8hpp.html#a4f04165526e37b9bc9715e2152600b14">SaveGuildIdByRole</a>(<span class="keyword">const</span> std::string &amp;service_name, <span class="keyword">const</span> std::string &amp;op,</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;                       <span class="keyword">const</span> <a class="code" href="guild_8h.html#a13864dd0b362015febe14be7a3960539">role_uuid_type</a> role_uuid,</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;                       <span class="keyword">const</span> <a class="code" href="guild_8h.html#a1c8a386d9790b05f2665f3e786b8d983">guild_id_type</a> guild_id) {</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;  std::stringstream ss;</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;  ss &lt;&lt; op &lt;&lt; <span class="stringliteral">&quot;role2guild:&quot;</span> &lt;&lt; role_uuid;</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;  <span class="keywordflow">if</span> (op == kRedisSetOp) {</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;    ss &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; guild_id;</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;  }</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160; </div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;  <span class="keyword">auto</span> result = redis_command_co(service_name, ss.str(), <a class="code" href="service__redis__client_8hpp.html#a1d1da97ea7897858a311261ebd3f59c6">kRedisCommonTimeOut</a>);</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;  <span class="keywordflow">if</span> (!result) {</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;    LOG_FAIL(<span class="stringliteral">&quot;redis处理失败 命令:%s 服务名:%s&quot;</span>, ss.str().c_str(),</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;             service_name.c_str());</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;  }</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;  <span class="keywordflow">if</span> (!result-&gt;is_success()) {</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;    LOG_FAIL(<span class="stringliteral">&quot;redis处理失败 命令:%s 错误:%s 错误码:%u 服务名:%s&quot;</span>,</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;             result-&gt;get_command().c_str(), result-&gt;get_error().c_str(),</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;             <span class="keyword">static_cast&lt;</span>uint32_t<span class="keyword">&gt;</span>(result-&gt;get_error_code()),</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;             service_name.c_str());</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;  }</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160; </div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;  LOG_DEBUG(<span class="stringliteral">&quot;redis保存角色id映射公会id成功 命令:(%s) 服务名:%s&quot;</span>,</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;            result-&gt;get_command().c_str(), service_name.c_str());</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160; </div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;}</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160; </div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;}  <span class="comment">// namespace detail</span></div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;}  <span class="comment">// namespace guild_service</span></div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aguild_8h_html_a1c8a386d9790b05f2665f3e786b8d983"><div class="ttname"><a href="guild_8h.html#a1c8a386d9790b05f2665f3e786b8d983">guild_service::guild_id_type</a></div><div class="ttdeci">uint64_t guild_id_type</div><div class="ttdoc">公会id类型</div><div class="ttdef"><b>Definition:</b> guild.h:31</div></div>
<div class="ttc" id="aguild_8h_html"><div class="ttname"><a href="guild_8h.html">guild.h</a></div><div class="ttdoc">公会定义</div></div>
<div class="ttc" id="aguild__saver_8hpp_html_a4f04165526e37b9bc9715e2152600b14"><div class="ttname"><a href="guild__saver_8hpp.html#a4f04165526e37b9bc9715e2152600b14">guild_service::detail::SaveGuildIdByRole</a></div><div class="ttdeci">bool SaveGuildIdByRole(const std::string &amp;service_name, const std::string &amp;op, const role_uuid_type role_uuid, const guild_id_type guild_id)</div><div class="ttdoc">同步保存角色唯一id获取公会id</div><div class="ttdef"><b>Definition:</b> guild_saver.hpp:75</div></div>
<div class="ttc" id="aservice__redis__fwd_8hpp_html"><div class="ttname"><a href="service__redis__fwd_8hpp.html">service_redis_fwd.hpp</a></div></div>
<div class="ttc" id="aservice__redis__client_8hpp_html_a1d1da97ea7897858a311261ebd3f59c6"><div class="ttname"><a href="service__redis__client_8hpp.html#a1d1da97ea7897858a311261ebd3f59c6">guild_service::kRedisCommonTimeOut</a></div><div class="ttdeci">constexpr uint32_t kRedisCommonTimeOut</div><div class="ttdoc">redis通用同步超时时间（单位 毫秒）</div><div class="ttdef"><b>Definition:</b> service_redis_client.hpp:120</div></div>
<div class="ttc" id="aguild__saver_8hpp_html_a86cddb3a9044df2a4587caca07618cf2"><div class="ttname"><a href="guild__saver_8hpp.html#a86cddb3a9044df2a4587caca07618cf2">guild_service::detail::SaveLastGuildId</a></div><div class="ttdeci">bool SaveLastGuildId(const std::string &amp;service_name, const guild_id_type guild_id)</div><div class="ttdoc">同步保存公会Id</div><div class="ttdef"><b>Definition:</b> guild_saver.hpp:40</div></div>
<div class="ttc" id="aguild_8h_html_a13864dd0b362015febe14be7a3960539"><div class="ttname"><a href="guild_8h.html#a13864dd0b362015febe14be7a3960539">guild_service::role_uuid_type</a></div><div class="ttdeci">uint64_t role_uuid_type</div><div class="ttdoc">角色唯一id类型</div><div class="ttdef"><b>Definition:</b> guild.h:32</div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="http://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.8.20
</small></address>
</body>
</html>
